function UI_CreateTheme ( name, image, imageset, defaulttheme )
	if ( name and image and imageset ) then
		for _, v in ipairs ( UI_Themes ) do
			if ( name == v["Name"] ) then
				return false
			end
		end

		table.insert ( UI_Themes, { ["Name"] = name, ["Image"] = image, ["ImageSet"] = imageset } )
		UI_ThemesSet[name] = { }
		local xml = xmlLoadFile ( imageset )
		if ( xml ) then
			for _, v in ipairs ( xmlNodeGetChildren ( xml ) ) do
				local Name = xmlNodeGetAttribute ( v, "Name" ) or "nil"
				local Xpos = xmlNodeGetAttribute ( v, "XPos" ) or 0
				local Ypos = xmlNodeGetAttribute ( v, "YPos" ) or 0
				local Width = xmlNodeGetAttribute (v, "Width" ) or 0
				local Height = xmlNodeGetAttribute ( v, "Height" ) or 0
				local Image = xmlNodeGetAttribute ( v, "Image" ) or image

				if ( not UI_ThemesSet[name][xmlNodeGetAttribute(v, "Name")] ) then
					UI_ThemesSet[name][xmlNodeGetAttribute(v, "Name")] = { }
				end
				UI_ThemesSet[name][xmlNodeGetAttribute(v, "Name")]["XPos"] = Xpos
				UI_ThemesSet[name][xmlNodeGetAttribute(v, "Name")]["YPos"] = Ypos
				UI_ThemesSet[name][xmlNodeGetAttribute(v, "Name")]["Width"] = Width
				UI_ThemesSet[name][xmlNodeGetAttribute(v, "Name")]["Height"] = Height
				UI_ThemesSet[name][xmlNodeGetAttribute(v, "Name")]["Image"] = Image
			end
		else
			table.remove ( UI_Themes, #UI_Themes )
			UI_ThemesSet[name] = nil
			return false
		end
		if ( defaulttheme ) then
			UI_ThemeDefault = name
		end
		return true
	end
	return false
end



function UI_CheckTheme ( name )
	for _, v in ipairs ( UI_Themes ) do
		if ( name == v["Name"] ) then
			return true
		end
	end
	return false
end

function UI_ThemeGetAll ( key, name )
	local theme = UI_CheckTheme ( name ) and name or UI_ThemeDefault
	if ( theme ) then
		return UI_ThemesSet[theme][key]["XPos"] or 0, UI_ThemesSet[theme][key]["YPos"] or 0,
		 UI_ThemesSet[theme][key]["Width"] or 0, UI_ThemesSet[theme][key]["Height"] or 0,
		 UI_ThemesSet[theme][key]["Image"] or "nil"
	end
end

function UI_ThemeGetXPos ( key, name )
	local theme = UI_CheckTheme ( name ) and name or UI_ThemeDefault
	if ( theme ) then
		return UI_ThemesSet[theme][key]["XPos"] or 0
	end
	return 0
end

function UI_ThemeGetYPos ( key, name )
	local theme = UI_CheckTheme ( name ) and name or UI_ThemeDefault
	if ( theme ) then
		return UI_ThemesSet[theme][key]["YPos"] or 0
	end
	return 0
end

function UI_ThemeGetWidth ( key, name )
	local theme = UI_CheckTheme ( name ) and name or UI_ThemeDefault
	if ( theme ) then
		return UI_ThemesSet[theme][key]["Width"] or 0
	end
	return 0
end

function UI_ThemeGetHeight ( key, name )
	local theme = UI_CheckTheme ( name ) and name or UI_ThemeDefault
	if ( theme ) then
		return UI_ThemesSet[theme][key]["Height"] or 0
	end
	return 0
end

function UI_ThemeGetImage ( key, name )
	local theme = UI_CheckTheme ( name ) and name or UI_ThemeDefault
	if ( theme ) then
		return UI_ThemesSet[theme][key]["Image"] or 0
	end
	return 0
end

function UI_SetDefaultTheme ( name )
	if ( UI_CheckTheme ( name ) ) then
		UI_ThemeDefault = name
		return true
	end
	return false
end